<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<div th:replace="/common/head :: head"></div>
<body>
<!-- 网站头部 -->
<div class="fly-header layui-bg-black" th:include="/common/header :: header"></div>

<!-- 帖子类型 -->
<div class="fly-panel fly-column" th:include="/common/column :: column"></div>

<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md8 content detail">
      <div class="fly-panel detail-box">
        <h1 th:text="${card.cardTitle}" >Fly Template v3.0，基于 layui 的极简社区页面模版</h1>
        <div class="fly-detail-info">
          <!-- 帖子状态标签 -->
          <span th:text="${card.cardType.cardTypeName}" class="layui-badge layui-bg-green fly-detail-column">动态</span>
          <span th:if="${card.cardType.cardTypeId==1 && card.cardUnfinished == 2}" class="layui-badge" style="background-color: #999;">未结</span>
          <span th:if="${card.cardUnfinished == 1}" class="layui-badge" style="background-color: #5FB878;">已结</span>
          <span th:if="${card.cardTop == 2}" class="layui-badge layui-bg-black">置顶</span>
          <span th:if="${card.cardEssence == 2}" class="layui-badge layui-bg-red">精帖</span>
          <!-- 管理员操作 -->
          <div sec:authorize="hasRole('ADMIN')" class="fly-admin-box" th:attr="data-id=${card.cardId}" >
             <span class="layui-btn layui-btn-xs jie-admin" type="del">删除</span>
             <span th:if="${card.cardTop == 1}" class="layui-btn layui-btn-xs jie-admin" type="set" field="stick" rank="2">置顶</span>
             <span th:if="${card.cardTop == 2}" class="layui-btn layui-btn-xs jie-admin" type="set" field="stick" rank="1" style="background-color:#ccc;">取消置顶</span>
             <span th:if="${card.cardEssence == 1}" class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="2">加精</span>
             <span th:if="${card.cardEssence == 2}" class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="1" style="background-color:#ccc;">取消加精</span>
          </div>

          <span class="fly-list-nums"> 
            <a href="#comment"><i class="iconfont" title="回答">&#xe60c;</i><span id="jiedaCount">[[${card.cardAnswerNumber}]]</span></a>
            <i class="iconfont" title="人气">&#xe60b;</i>[[${card.cardLookNumber}]]
          </span>

        </div>
        <div class="detail-about">
          <a class="fly-avatar" th:href="${'/user/username/'+card.user.username}" href="/user/home.html">
            <img th:src="${card.user.userImage}" th:alt="${card.user.username}" alt="贤心">
          </a>
          <div class="fly-detail-user">
            <a th:href="${'/user/username/'+card.user.username}" href="/user/home.html" class="fly-link">
              <cite th:text="${card.user.username}">贤心</cite>
            </a>
            <span th:text="${#temporals.format(card.cardCreateTime, 'yyyy/MM/dd HH:mm')}">2017-11-30</span>
          </div>
          <div  class="detail-hits" id="LAY_jieAdmin" th:attr="data-id=${card.cardId}">
            <span th:if="${ #authentication.principal != 'anonymousUser' && #authentication.principal.userId == card.user.userId }" class="layui-btn layui-btn-xs jie-admin" type="edit">
              <a  th:href="'/jie/edit/'+${card.cardId}" href="edit.html">编辑此贴</a>
            </span>
            <span class="layui-btn layui-btn-xs jie-admin" style="opacity: 0;" ></span>
          </div>
        </div>
        <!-- 内容 -->
        <div class="detail-body photos" th:text="${card.cardContent}"></div>
      </div>
      <!-- 回帖 -->
      <div class="fly-panel detail-box" id="flyReply">
        <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
          <legend>回帖</legend>
        </fieldset>

        <ul class="jieda" id="jieda">
          <li th:each="replies : ${repliesList}" th:attr="data-id=${replies.repliesId},data-card-id=${card.cardId}" data-id="111">
            <a name="item-1111111111"></a>
            <div class="detail-about detail-about-reply">
              <a class="fly-avatar" th:href="${'/user/username/'+replies.user.username}">
                <img th:src="${replies.user.userImage}" th:alt="${replies.user.username}" alt="">
              </a>
              <div class="fly-detail-user">
                <a th:href="${'/user/username/'+replies.user.username}" href="" class="fly-link">
                  <cite th:text="${replies.user.username}">贤心</cite>
                </a>
              </div>
              <div class="detail-hits">
                <span th:text="${#temporals.format(replies.repliesTime, 'yyyy-MM-dd HH:mm')}">2017-11-30</span>
              </div>
              <i th:if="${replies.repliesStatus == 2}" class="iconfont icon-caina" title="最佳答案"></i>
            </div>
            <div class="detail-body jieda-body photos" th:text="${replies.repliesContent}"></div>
            <div class="jieda-reply">
              <!--  点赞 待完成 -->
              <span class="jieda-zan" type="zan">
                <i class="iconfont icon-zan"></i>
                <em th:text="${replies.repliesPraiseNumber}">0</em>
              </span>
              <!-- 回复 -->
              <span type="reply" th:if="${ #authentication.principal != 'anonymousUser' && #authentication.principal.userId != replies.user.userId }">
                <i  class="iconfont icon-svgmoban53"></i>
                回复
              </span>
              <div sec:authorize="isAuthenticated()" class="jieda-admin">
                <!--<span sec:authorize="hasRole('ADMIN')" type="edit">编辑</span>-->
                <span sec:authorize="hasRole('ADMIN')" type="del">删除</span>
                <span th:if="${ #authentication.principal != 'anonymousUser' && #authentication.principal.userId == card.user.userId && card.cardType.cardTypeId== 1 && #authentication.principal.userId != replies.user.userId && card.CardRepliesStatus == 1}"  class="jieda-accept" type="accept">采纳</span>
              </div>
            </div>
          </li>
          
          <!-- 无数据时 -->
          <li th:if="${repliesList.size() <= 0}" class="fly-none">消灭零回复</li>
        </ul>

        <!-- 分页 -->
        <div th:if="${count >10 }" style="text-align: center" id="fen-page"></div>
        <!-- 回帖表单 -->
        <div class="layui-form layui-form-pane">

          <form action="/replies/reply/" method="post">
            <div class="layui-form-item layui-form-text">
              <a name="comment"></a>
              <div class="layui-input-block">
                <textarea id="L_content" name="repliesContent" required lay-verify="required" placeholder="请输入内容"  class="layui-textarea fly-editor" style="height: 150px;"></textarea>
              </div>
            </div>
            <div class="layui-form-item">
              <!-- 本帖ID-->
              <input type="hidden" name="cardId" th:value="${card.cardId}">
              <!-- 当前用户ID -->
              <input type="hidden" name="userId" th:if="${#authentication.principal != 'anonymousUser' }" th:value="${#authentication.principal.userId}">
              <button class="layui-btn"  lay-filter="*" lay-submit>提交回复</button>
            </div>
          </form>


        </div>
      </div>
    </div>
    <div class="layui-col-md4">
      <!--  友情链接 -->
      <div class="fly-panel frielink" th:include="/common/frielink :: frielink" ></div>
      <!--  微信公众号 -->
      <div class="fly-panel weixin" style="padding: 20px 0; text-align: center;"  th:include="/common/weixin :: weixin"></div>
    </div>
  </div>
</div>

<!-- 页尾 -->
<div th:replace="/common/footer :: footer"></div>

</body>
</html>